package collection;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;

public class CollectinDemo1 {
    public static void main(String[] args) {
        //Collection c=new ArrayList();
        Collection c=new HashSet();//不可放重复元素，并且无序
        boolean b=c.add("one");
        c.add("two");
        c.add("three");
        c.add("four");
        c.add("five");
        System.out.println(c);
        b=c.add("one");//存放重复元素
        System.out.println(b);
        System.out.println(c);

        int size=c.size();//返回集合长度
        System.out.println("size="+size);

        boolean isEmpty =c.isEmpty();
        System.out.println("isEmpty="+isEmpty);

        c.clear();
        System.out.println(c);
        System.out.println("size="+c.size());
        System.out.println("isEmpty="+c.isEmpty());
    }
}
